package com.yiqi.liebang.feature.news.model;

import com.suozhang.framework.component.http.RxDataProcessFactory;
import com.yiqi.liebang.entity.bo.IssuesBo;
import com.yiqi.liebang.entity.bo.OtherUserId;
import com.yiqi.liebang.entity.bo.PeopleBo;
import com.yiqi.liebang.entity.bo.RelationshipBo;
import com.yiqi.liebang.feature.news.contract.IssuesContract;
import com.yiqi.liebang.feature.news.contract.RelationshipContract;
import com.yiqi.liebang.feature.news.dependencies.issues.DaggerIssuesModelComponent;
import com.yiqi.liebang.feature.news.dependencies.relationship.DaggerRelationshipModelComponent;
import com.yiqi.liebang.framework.api.ApiLib;
import com.yiqi.liebang.framework.api.HomeApi;
import com.yiqi.liebang.framework.api.UserApi;

import java.util.List;

import javax.inject.Inject;

import io.reactivex.Observable;

public class RelationshipModel implements RelationshipContract.Model {

    @Inject
    HomeApi api;


    @Inject
    public RelationshipModel() {
        DaggerRelationshipModelComponent.builder().apiComponent(ApiLib.apiComponent()).build().inject(this);
    }


    @Override
    public Observable<String> deleteFriend(RelationshipBo relationshipBo) {
        return api.deleteUser(relationshipBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> addBlack(RelationshipBo id) {
        return api.addBlackList(id).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> isFriend(OtherUserId id) {
        return api.isFriend(id).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> commitAddFriend(PeopleBo registerBo) {
        return api.getAddFriend(registerBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }
}
